import 'package:meiyunapp/entity/home_top_data_entity.dart';

homeTopDataEntityFromJson(HomeTopDataEntity data, Map<String, dynamic> json) {
	if (json['banners'] != null) {
		data.banners = (json['banners'] as List).map((v) => HomeTopDataBanners().fromJson(v)).toList();
	}
	if (json['popunAdvert'] != null) {
		data.popunAdvert = HomeTopDataPopunAdvert().fromJson(json['popunAdvert']);
	}
	if (json['categories'] != null) {
		data.categories = (json['categories'] as List).map((v) => HomeTopDataCategories().fromJson(v)).toList();
	}
	if (json['limitTimeActive'] != null) {
		data.limitTimeActive = (json['limitTimeActive'] as List).map((v) => HomeTopDataLimitTimeActive().fromJson(v)).toList();
	}
	if (json['notReadMessageCount'] != null) {
		data.notReadMessageCount = json['notReadMessageCount'] is String
				? int.tryParse(json['notReadMessageCount'])
				: json['notReadMessageCount'].toInt();
	}
	return data;
}

Map<String, dynamic> homeTopDataEntityToJson(HomeTopDataEntity entity) {
	final Map<String, dynamic> data = <String, dynamic>{};
	data['banners'] =  entity.banners.map((v) => v.toJson()).toList();
	data['popunAdvert'] = entity.popunAdvert.toJson();
	data['categories'] =  entity.categories.map((v) => v.toJson()).toList();
	data['limitTimeActive'] =  entity.limitTimeActive.map((v) => v.toJson()).toList();
	data['notReadMessageCount'] = entity.notReadMessageCount;
	return data;
}

homeTopDataBannersFromJson(HomeTopDataBanners data, Map<String, dynamic> json) {
	if (json['appid'] != null) {
		data.appid = json['appid'] is String
				? int.tryParse(json['appid'])
				: json['appid'].toInt();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['image'] != null) {
		data.image = json['image'].toString();
	}
	if (json['link'] != null) {
		data.link = json['link'] is String
				? int.tryParse(json['link'])
				: json['link'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['remark'] != null) {
		data.remark = json['remark'].toString();
	}
	if (json['type'] != null) {
		data.type = json['type'] is String
				? int.tryParse(json['type'])
				: json['type'].toInt();
	}
	return data;
}

Map<String, dynamic> homeTopDataBannersToJson(HomeTopDataBanners entity) {
	final Map<String, dynamic> data = <String, dynamic>{};
	data['appid'] = entity.appid;
	data['id'] = entity.id;
	data['image'] = entity.image;
	data['link'] = entity.link;
	data['name'] = entity.name;
	data['remark'] = entity.remark;
	data['type'] = entity.type;
	return data;
}

homeTopDataPopunAdvertFromJson(HomeTopDataPopunAdvert data, Map<String, dynamic> json) {
	if (json['appid'] != null) {
		data.appid = json['appid'] is String
				? int.tryParse(json['appid'])
				: json['appid'].toInt();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['image'] != null) {
		data.image = json['image'].toString();
	}
	if (json['link'] != null) {
		data.link = json['link'] is String
				? int.tryParse(json['link'])
				: json['link'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['remark'] != null) {
		data.remark = json['remark'].toString();
	}
	if (json['type'] != null) {
		data.type = json['type'] is String
				? int.tryParse(json['type'])
				: json['type'].toInt();
	}
	return data;
}

Map<String, dynamic> homeTopDataPopunAdvertToJson(HomeTopDataPopunAdvert entity) {
	final Map<String, dynamic> data = Map<String, dynamic>();
	data['appid'] = entity.appid;
	data['id'] = entity.id;
	data['image'] = entity.image;
	data['link'] = entity.link;
	data['name'] = entity.name;
	data['remark'] = entity.remark;
	data['type'] = entity.type;
	return data;
}

homeTopDataCategoriesFromJson(HomeTopDataCategories data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['icon'] != null) {
		data.icon = json['icon'].toString();
	}
	return data;
}

Map<String, dynamic> homeTopDataCategoriesToJson(HomeTopDataCategories entity) {
	final Map<String, dynamic> data = Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['icon'] = entity.icon;
	return data;
}

homeTopDataLimitTimeActiveFromJson(HomeTopDataLimitTimeActive data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'] is String
				? int.tryParse(json['name'])
				: json['name'].toInt();
	}
	if (json['image'] != null) {
		data.image = json['image'].toString();
	}
	if (json['zipImage'] != null) {
		data.zipImage = json['zipImage'].toString();
	}
	if (json['endTi'] != null) {
		data.endTi = json['endTi'].toString();
	}
	if (json['endTime'] != null) {
		data.endTime = json['endTime'] is String
				? int.tryParse(json['endTime'])
				: json['endTime'].toInt();
	}
	if (json['now'] != null) {
		data.now = json['now'] is String
				? int.tryParse(json['now'])
				: json['now'].toInt();
	}
	if (json['price'] != null) {
		data.price = json['price'] is String
				? int.tryParse(json['price'])
				: json['price'].toInt();
	}
	if (json['salesCount'] != null) {
		data.salesCount = json['salesCount'] is String
				? int.tryParse(json['salesCount'])
				: json['salesCount'].toInt();
	}
	return data;
}

Map<String, dynamic> homeTopDataLimitTimeActiveToJson(HomeTopDataLimitTimeActive entity) {
	final Map<String, dynamic> data = <String, dynamic>{};
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['image'] = entity.image;
	data['zipImage'] = entity.zipImage;
	data['endTi'] = entity.endTi;
	data['endTime'] = entity.endTime;
	data['now'] = entity.now;
	data['price'] = entity.price;
	data['salesCount'] = entity.salesCount;
	return data;
}